#!/bin/bash

# 1- evn path
HIVE_HOME=/usr/bin/hive

# 2- Tran
if [ $# == 5 ]
then
	dateStr=$5
else
	dateStr=`data -d '-1 day' +'%Y-%m-%d'`

fi

# 3- sqoop
SQOOP_HOME=/usr/bin/sqoop
username='bjclass58'
password='bjclass58_itcast'

url="jdbc:mysql://106.75.33.59:3306/$1?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true"

${SQOOP_HOME} import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect ${url} \
--username ${username} \
--password ${password} \
--query "select *, '${dateStr}' as $3 from $2 where 1=1 and
\$CONDITIONS" \
--hcatalog-database 'ods_zhixing04' \
--hcatalog-table $4 \
--fields-terminated-by  '\t' \
-m 1
